package arch.coal.ellipse.security.data;

import org.apache.log4j.Logger;



public class Item {
	
	static Logger logger = Logger.getLogger(Item.class);
	private String name;
	private char[] nameParsed;
	private int[] nameParsedAsInt;
	
	public int[] getNameParsedAsInt() {
		return nameParsedAsInt;
	}

	public Item(String inName) {
		setName(inName);
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
		
		if( name != null &&
			name.length() > 0 ) {
			
			nameParsed = new char[name.length() + 1];
			nameParsedAsInt = new int[name.length() + 1];
			
			for(int loop=0; loop<name.length(); loop++) {
				nameParsed[loop] = name.charAt(loop);
				nameParsedAsInt[loop] = name.charAt(loop);
			}
		}
		else {
			logger.error(" ** ERROR in Item.setName() ...");
			logger.error("String not properly populated.");
		}
		return;
	}
	
	public char[] getNameParsed() {
		return nameParsed;
	}
	
	public String getNameParsed_toString() {
		StringBuffer sb = new StringBuffer();
		
		for(int loop=0; loop<nameParsed.length; loop++) {
			sb.append(nameParsed[loop]);
			sb.append("|");
		}
		sb.append("X");
		
		return sb.toString();
	}
	
	public String getNameParsedAsInt_toString() {
		StringBuffer sb = new StringBuffer();
		
		for(int loop=0; loop<nameParsed.length; loop++) {
			sb.append(nameParsed[loop]);
			sb.append("|");
		}
		sb.append("X");
		
		return sb.toString();
	}

}
